package com.example.springboot.mapper;

import com.example.springboot.entity.Course_select;
import com.example.springboot.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface Course_selectMapper  {
    @Select("SELECT * FROM course_select")
    List<Course_select> findAll();

    @Insert("insert into course_select(course_id,student_id) " +
            " values(#{course_id}, #{student_id})")
    int insert(Course_select course);

    int update(Course_select course_select);
    @Delete("delete from course_select  where course_select_id =#{course_select_id}")
    Integer delete(@Param("course_select_id") Integer id) ;
    @Select("select * from course_select limit #{pageNum}, #{pageSize} ")
    List<Course_select> selectPage(Integer pageNum,Integer pageSize);
    @Select("select count(*) from course_select")
    Integer selectTotal();

    @Select("SELECT course_time FROM course_sort,course_select WHERE course_sort.course_id = course_select.course_id and  student_id = #{stuID} and course_time = #{course_time} ;  ")
    List<Integer> finndCourse(Integer stuID,Integer course_time);
    @Select("select  select_time from  course_select where course_id = #{course_id} and student_id = #{student_id}")
    String GetselectTime(Integer course_id, Integer student_id);
    @Select("SELECT student.*, course_select.grade FROM student,course_select WHERE course_id = #{course_id} and course_select.student_id = student.student_id")
    List<Student> getStudentOfCourse(Integer course_id);
}

